Conversation
| # copy | ||
| mkdir -p /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/ | ||
| cp tcc.cwasm ../lindfs/ | ||
| cp libtcc1.a /home/lind/lind-wasm/lindfs/usr/local/lib/tcc/ |
There was a problem hiding this comment.
libtcc1.a is not statically compiled with tinycc and is copied to lib/ folder. This is a static build of tinycc right. In that case I suppose, you need to pass libtcc as a dependent library (ldflags) during compilation phase. Essentially we need to have compilation of libtcc1 under 'merge-sysroot' in the main Makefile of the app and the built library should be placed under sysroot_merged folder and have ldflags have syroot_merged folder in its arguments (-I) like this.
lind-wasm-apps/curl/compile_curl.sh
Line 73 in 39b15e4
@rennergade @qianxichen233 Could you pls confirm this?
There was a problem hiding this comment.
Sysroot is used by clang to compile wasm binary. libtcc1.a is not used by clang. It's used by tcc during compiling the native code, so it should be placed in lindfs not sysroot.
|
@qianxichen233 @rennergade Could you please review this? |
|
|
||
| # libtcc.a is a shared library that is required to run tinycc. Since the target is i386, libtcc.a is also compiled as i386. | ||
|
|
||
| # The required header files, shared libraries and other files (libc.so, ld.so, libc_nonshared.a, crt1.o) which are required to run tinycc is also copied to the build/ folder. |
There was a problem hiding this comment.
Not required to "run tcc" but to compile correct native binary that can be run on native
…ion and copying to build folder of app repo
…nycc to the build folder
ed12508 to
2ae38d4
Compare
rennergade
left a comment
There was a problem hiding this comment.
A few things to address:
-
Doesn't use
.toolchain.env— hardcodesCLANG_BINpath instead of loading from the standard toolchain env like all other compile scripts. Should follow thecompile_gcc.sh/compile_grep.shpattern. -
Copy-paste log tag:
echo "[git] generating cwasm..."should be[tinycc] -
sudoin build script — runssudo ln -sandsudo ldconfigat the end. Build scripts should not require sudo — this should be handled separately or documented as a manual step. -
Copies host system files (
/usr/i686-linux-gnu/lib/crt*.o,libc.so, etc.) — assumes a specific host layout. Won't work in different environments. -
set -xinstead ofset -euo pipefail— dumps every command to stdout with no proper error handling. Other scripts useset -euo pipefail. -
-g -O0in CFLAGS — unoptimized debug build. Should at least use-O2or-Osfor the final artifact. -
LIND_BOOTdefined twice — once as a debug path on line 22, then overridden with the standard default on line 66. -
|| trueafter wasm-opt — silently swallows optimization failures. If wasm-opt fails, the build should fail. -
tcc_headers.tar.gz— committed binary blob. Should be generated during the build or documented how to produce it. -
clean.shdoesn't handle missing files gracefully — will error if files don't exist. Userm -f/rm -rfor add|| true.
Resolves #91
Added build script required to compile tinycc for lind-wasm.
The compiled tinycc compiler can compile C programs to 32-bit ELF binaries (i386 target)
Since the target is i386, the dependent library
libtcc.ais compiled using as a i386 shared folder using gcc. Also, in order to run tinycc, the following are required:libc.so.6,ld.so,libc_nonshared.a,crt1.oThe above are also copied to the build/ folder and later copied to lindfs when
make install-tinyccis run.To run dynamically linked executables produced by tinycc, dynamic linker is used. Since the executable is run natively, we provide a symbolic link to the 32-bit dynamic linker within
/libof the root filesystem so that the kernel can locate the dynamic linker.Steps to reproduce